<?php

session_start();
include('config.php');
$option = $_POST['option'];
if ($option == 'addProduct') {
    echo '<form action="inc/addProduct.php" target="A" method="post" enctype="multipart/form-data">
                    <iframe src="" name="A" width="1px" height="1px"></iframe> 
                    <div id="addProductArea">

                        <div id="productImageArea">
                            <div id="productImage"><img src="./images/productImage.png"/></div>
                            <div id="imageInput" ><input type="file" name="myfile" id="productFile"/></div>
                        </div>
                        <div id="productInfo">
                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Title</p> </div>    
                                <div class="infoBarInput"> <input type="text" id="title" name="title"/> </div>
                            </div>

                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Descreption</p> </div>    
                                <div class="infoBarInput"> <textarea name="desc" id="productDesc"></textarea> </div>
                            </div>

                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Price</p> </div>    
                                <div class="infoBarInput"> <input type="text" id="price" name="price" id="productPrice"/> </div>
                            </div>
                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Discount</p> </div>    
                                <div class="infoBarInput"> <input type="text" id="discount" name="discount" id="productPrice"/> </div>
                            </div>
                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Categorie</p> </div>    
                                <div class="infoBarInput"> 
                                    <select id="category"> ';
    $sql = "SELECT * FROM `category`";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        echo '<option value="' . $row['id'] . '">' . $row['title'] . '</option>';
    }
    echo '</select>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div id="productButtons">
                        <div id="addProductButtons">
                            <input type="submit" id="AddProductButton" value="Add"/>
                            <input type="reset" id="clearProductButton" value="Clear All"/>
                        </div>
                    </div>
                </form>';
}
/* * *************************************** */
/* * *************************************** */
/* * *************************************** */
/* * *************************************** */
if ($option == 'manageProducts') {
    echo '<table id="productsTable">
                    <tr style="background-color: #0080C0; color: white; text-align: left; font-weight: 600;">
                        <td>Product Title</td>
                        <td>Description</td>
                        <td>Price</td>
                        <td>Discount</td>
                        <td>Active</td>
                        <td></td>
                    </tr>';

    $sql = "SELECT * FROM `product`";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        echo '<tr>
                        <td>
                        <input type="text" id="productTitle" value="' . $row['title'] . '"/></td>
                        <td><input type="text" id="description" value="' . $row['descreption'] . '"/></td>
                        <td><input type="text" id="priceValue" value="' . $row['price'] . '"/></td>
                        <td><input type="text" id="discountValue" value="' . $row['discount'] . '"/></td>
                        <td>
                            <select id="statusCombo">
                                <option value="1">Active</option>
                                <option value="0">Not Active</option>
                            </select>
                        </td>
                            <td>
                                <a href="javascript:void(0);" title="delete" class="delete" content="' . $row['id'] . '"><img src="images/delete.png" width="20px;" content="' . $row['id'] . '" style="float:right; margin-right:20px;"/></a>
                                <a href="editProduct.php?id='.$row['id'].'" title="update" calss="update" ><img src="images/update.png" class="update" content="' . $row['id'] . '" width="20px;" style="float:right; margin-right:10px;"/></a>
                            </td>
                        
                        </tr>';
    }

    echo '</table>';
}

/* * **************************************** */
/* * **************************************** */
/* * **************************************** */
/* * **************************************** */
if ($option == 'manageUsers') {
    echo '
                    <iframe src="" name="A" width="1px" height="1px"></iframe> 
        <table id="productsTable">
                    <tr style="background-color: #0080C0; color: white; text-align: left; font-weight: 600;">
                        <td>First Name</td>
                        <td>Last Name</td>
                        <td>User Name</td>
                        <td>Password</td>
                        <td>Active</td>
                        <td></td>
                    </tr>';

    $sql = "SELECT * FROM `user`";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {

        echo '<tr>
                        <td>
                            <form action="inc/updateUser.php" target="A" method="post" enctype="multipart/form-data">
                            <input type="text" name="fname" value="' . $row['firstName'] . '"/>
                            </form>
                        </td>
                        <td>
                            <form action="inc/updateUser.php" target="A" method="post" enctype="multipart/form-data">
                            <input type="text" name="lname" value="' . $row['lastName'] . '"/>
                            </form>
                        </td>
                        <td>
                            <form action="inc/updateUser.php" target="A" method="post" enctype="multipart/form-data">
                            <input type="text" name="username" value="' . $row['userName'] . '"/>
                            </form>
                        </td>
                        <td><input type="text" name="password" value="' . $row['password'] . '"/></td>
                        <td>
                            <select name="status">
                                <option value="1">Active</option>
                                <option value="0">Not Active</option>
                            </select>
                        </td>
                            <td>';
        echo '<a href="javascript:void(0);" title="deleteUser" class="deleteUser" content="' . $row['id'] . '"><img src="images/delete.png" width="20px;" content="' . $row['id'] . '" style="float:right; margin-right:20px;"/></a>
                <input type="submit" value="update" class="updateInput"/>
                </td>
                </tr>';
//        echo '<a href="javascript:void(0);" title="deleteUser" class="deleteUser" content="' . $row['id'] . '"><img src="images/delete.png" width="20px;" content="' . $row['id'] . '" style="float:right; margin-right:20px;"/></a>
//            <a href="javascript:void(0);" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1" title="updateUser" calss="updateUser" content="' . $row['id'] . '"><img src="images/update.png" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1"  class="updateUser" content="' . $row['id'] . '" width="20px;" style="float:right; margin-right:10px;"/></a>
//                </td>
//                </tr>';
//        if ($_SESSION['id'] == $row['id']) {
//            echo '
//                    <a href="javascript:void(0);" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1" title="updateUser" calss="updateUser" content="' . $row['id'] . '"><img src="images/update.png" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1"  class="updateUser" content="' . $row['id'] . '" width="20px;" style="float:right; margin-right:10px;"/></a>
//                </td>
//                </tr>';
//        }else{
//            echo '<a href="javascript:void(0);" title="deleteUser" class="deleteUser" content="' . $row['id'] . '"><img src="images/delete.png" width="20px;" content="' . $row['id'] . '" style="float:right; margin-right:20px;"/></a>
//                    <a href="javascript:void(0);" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1" title="updateUser" calss="updateUser" content="' . $row['id'] . '"><img src="images/update.png" firstName="' . $row['firstName'] . '" lastName="' . $row['lastName'] . '" userName="' . $row['userName'] . '" password="' . $row['password'] . '" userStatus="1"  class="updateUser" content="' . $row['id'] . '" width="20px;" style="float:right; margin-right:10px;"/></a>
//                </td>
//                </tr>';
//        }
    }

    echo '</table>
        </form>'
    ;
}
if ($option == 'addNews') {
    echo '<form action="inc/addNews.php" target="A" method="post" enctype="multipart/form-data">
                    <iframe src="" name="A" width="1px" height="1px"></iframe> 
                    <div id="addProductArea">

                        <div id="productImageArea">
                            <div id="productImage"><img src="./images/productImage.png"/></div>
                            <div id="imageInput" ><input type="file" name="myfile" id="productFile"/></div>
                        </div>
                        <div id="productInfo">
                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Title_ar</p> </div>    
                                <div class="infoBarInput"> <input type="text" id="title_ar" name="title_ar"/> </div>
                            </div>
                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Title_en</p> </div>    
                                <div class="infoBarInput"> <input type="text" id="title_en" name="title_en"/> </div>
                            </div>

                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Descreption_ar</p> </div>    
                                <div class="infoBarInput"> <textarea name="desc_ar" id="productDesc"></textarea> </div>
                            </div>

                            <div class="infoBar">
                                <div class="infoBarTitle"> <p>Descreption_en</p> </div>    
                                <div class="infoBarInput"> <textarea name="desc_en" id="productDesc"></textarea> </div>
                            </div>

                    </div>
                    <div id="productButtons">
                        <div id="addProductButtons">
                            <input type="submit" id="AddProductButton" value="Add"/>
                            <input type="reset" id="clearProductButton" value="Clear All"/>
                        </div>
                    </div>
                </form>';
}
?>
